/**
 * LoginAction.java
 * jp.co.greenblue.ecodasweb.web.struts.action
 *
 * Function??TODO 
 *
 *   ver     date      		author
 * �?���?���?���?���?���?���?���?���?���?���?���?���?���?���?���?���?��
 *   		 2010/11/04 		jonsion
 *
 * Copyright (c) 2010, GreenBlue .  All Rights Reserved.
 */

package jp.co.greenblue.ecodasweb.web.struts2.action;

import jp.co.greenblue.ecodasweb.domain.User;
import jp.co.greenblue.ecodasweb.service.IJinHuService;
import jp.co.greenblue.ecodasweb.service.IUserService;

/**
 * ClassName:LoginAction Function: TODO ADD FUNCTION Reason: TODO ADD REASON
 * 
 * @author jonsion
 * @version
 * @since Ver 1.1
 * @Date 2010/11/04 16:17:20
 * 
 * @see
 */
public class UserAction extends BaseAction {
	private IUserService userService;
	private IJinHuService jinHuService;
	public User user;

	public String execute() {
		boolean flag=userService.canLogin(user.getUserName(), user.getPassWord());
		if (!flag) {
			super.addFieldError("username", "用户名错误");
			return ERROR;
		}
		session.put("userName", user.getUserName());
		session.put("jinhulist", jinHuService.viewAll());
		return SUCCESS;
	}

	public void validate() {
		if (user.getUserName() == null || user.getUserName().length() == 0) {
			super.addActionError("用户名不能为空");
		}
		if (user.getPassWord() == null || user.getPassWord().length() == 0) {
			super.addActionError("密码不能为空");
		}
	}

	public void setUserService(IUserService userService) {
		this.userService = userService;
	}

	public void setJinHuService(IJinHuService jinHuService) {
		this.jinHuService = jinHuService;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}



}
